package main

import (
	snailjob "github.com/open-snail/snail-job-go"
	"github.com/open-snail/snail-job-go/dto"
	"github.com/open-snail/snail-job-go/example/demo"
	"github.com/open-snail/snail-job-go/job"
)

func main() {

	co := dto.NewClientOptions(
		dto.WithServerHost("127.0.0.1"),
		// dto.WithServerPort("17888"),
		dto.WithHostIP("127.0.0.1"),
		// dto.WithHostPort("17889"),
		dto.WithNamespace("764d604ec6fc45f68cd92514c40e9e1a"),
		dto.WithGroupName("snail_job_demo_group"),
		dto.WithToken("SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj"),
		dto.WithLabels("env:dev,app:demo"),
		// dto.WithLogLevel(logrus.InfoLevel),
		// dto.WithReportCaller(true),
	)
	exec := snailjob.NewSnailJobManager(co)

	exec.Register("testJobExecutor", func() job.IJobExecutor {
		return &demo.TestJobExecutor{}
	}).Register("test2JobExecutor", func() job.IJobExecutor {
		return &demo.Test2JobExecutor{}
	}).Register("testMapJobExecutor", func() job.IJobExecutor {
		return &demo.TestMapJobExecutor{}
	}).Register("testMapReduceJobExecutor", func() job.IJobExecutor {
		return &demo.TestMapReduceJobExecutor{}
	}).Register("testWorkflowJobExecutor", func() job.IJobExecutor {
		return &demo.TestWorkflowJobExecutor{}
	})

	if nil == exec.Init() {
		exec.Run()
	}

}
